package yxxy.c_01;


/**
 * synchronized关键字
 * 对某个对象加锁
 * @author mashibing
 */
public class T {
    private static int count = 10 ;
    private Object o = new Object();

    public static void main(String[] args) {
       T t = new T();
       t.m();
    }

    public void m(){
        synchronized(o){//任何线程执行以下代码必须先拿到o的锁
            count--;
            System.out.println(Thread.currentThread().getName()+" count = "+count );
        }
    }
}
